package com.shuiyun.jtt1078.utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * @author shuiyun
 * @program jtt1078
 * @description 配置获取工具类
 * @date 2021-09-06 11:35
 **/
public class PropertiesUtil {

    public static final String ON = "on";

    public static String get(String key){
        String result =null;
        Properties properties = new Properties();
        InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream("rtmp.properties");
        try {
            properties.load(in);
            result = properties.getProperty(key);
        }catch (Exception e){
            throw new RuntimeException("获取配置文件失败",e);
        }
        return result;
    }

    public static Integer getInt(String key){
        return Integer.parseInt(get(key));
    }

    public static Integer getInt(String key,Integer defaultValue){
        try {
            return Integer.parseInt(get(key));
        }catch (Exception e){
            return defaultValue;
        }
    }
}
